# $Id: PKGBUILD 177825 2013-02-09 17:43:46Z andyrtr $
# Maintainer: Jan de Groot <jgc@archlinux.org>

pkgname=libdrm
pkgver=2.4.42
pkgrel=1
pkgdesc="Userspace interface to kernel DRM services"
arch=(i686 x86_64 sh4)
license=('custom')
depends=('glibc' 'libpciaccess')
makedepends=('cairo')
replaces=('libdrm-new' 'libdrm-nouveau')
options=('!libtool')
url="http://dri.freedesktop.org/"
source=(http://dri.freedesktop.org/$pkgname/$pkgname-$pkgver.tar.bz2
        no-pthread-stubs.patch
        COPYING)
sha256sums=('e0671082a77871c8474d3c0f09dbf5ff82d2429cd248088a691f7b484cbc76e1'
            '3915aaff4d5b0ed523c3144911e7f79ee812dece0e3933c13a88dddcf5912ded'
            '9631d4f694952e3e6ae5a05534c2e93e994e47d3413677a3a00e45c8cef6db93')

build() {
  cd $pkgname-$pkgver
  patch -Np1 -i ../no-pthread-stubs.patch

  #libtoolize --force
  autoreconf --force --install
  ./configure --prefix=/usr \
      --enable-udev \
      --enable-omap-experimental-api \
      --enable-exynos-experimental-api
  sed -i 's/fcntl.h/asm-generic\/fcntl.h/' nouveau/nouveau.c
  sed -i 's/fcntl.h/asm-generic\/fcntl.h/' radeon/radeon_bo_gem.c
  sed -i 's/fcntl.h/asm-generic\/fcntl.h/' omap/omap_drm.c

#  sed -i '1 i\
#include <asm-generic/fcntl.h>' radeon/radeon_bo_gem.c
  make CFLAGS=-D_GNU_SOURCE
}

check() {
  cd $pkgname-$pkgver
  make -k check
}

package() {
  cd $pkgname-$pkgver
  make DESTDIR="$pkgdir" install
  install -m755 -d "$pkgdir/usr/share/licenses/$pkgname"
  install -m644 ../COPYING "$pkgdir/usr/share/licenses/$pkgname/"
}
